package com.icare.shop.server.service;

import com.icare.common.service.utils.BeanMapper;
import com.icare.shop.server.api.ShopService;
import com.icare.shop.server.domain.Goods;
import com.icare.shop.server.mapper.GoodsExtMapper;
import com.icare.shop.server.resp.GoodsResp;
import com.icare.shop.server.rest.ShopRest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <pre>
 *    author  : tianhaibo
 *    email   : tianhaibo@jshuii.com
 *    time    : 2020/4/13   19:00
 *    desc    :
 *    version : v1.0
 * </pre>
 */
@Slf4j
@Service
public class ShopServiceImpl implements ShopService {

    @Autowired
    private GoodsExtMapper goodsMapper;

    @Autowired
    private ShopRest shopRest;

    @Override
    @Transactional
    public GoodsResp getGoods(Long id) {
        Goods goods = goodsMapper.getGoods(id);
        Goods goods2 = goodsMapper.getGoods(id);
        if(goods!=null){
            GoodsResp map = BeanMapper.map(goods, GoodsResp.class);
            return map;
        }
        return null;
    }

    @Override
    public GoodsResp getGoodsNoTransaction(Long id) {
        Goods goods = goodsMapper.getGoods(id);
        Goods goods2 = goodsMapper.getGoods(id);
        if(goods!=null){
            GoodsResp map = BeanMapper.map(goods, GoodsResp.class);
            return map;
        }
        return null;
    }
}
